import React, { PureComponent } from 'react'
import PubSubJS from 'pubsub-js'
import { Switch } from "antd-mobile"

export default class More extends PureComponent {
    state = {
        checked: true
    }

    // componentDidMount() {
    //     console.log(this.state.checked);
    //     
    // }

    // shouldComponentUpdate(_, nextState) {
    //     if (this.state.checked === nextState.checked) {
    //         return false
    //     } else {
    //         PubSubJS.publish("mapShowChecked", ({mapTabBarShow: nextState.checked}))
    //         return true
    //     }
    // }

    componentDidUpdate() {
        PubSubJS.publish("mapShowChecked", ({mapTabBarShow: this.state.checked}))
    }

    render() {
        console.log("render--",this.state.checked);
        return (
            <div>
                是否显示地图： <Switch
                    checked={this.state.checked}
                    onChange={() =>  this.setState((state) => ({checked: !state.checked}))
                    }
                />
            </div>
        )
    }
}
